package com.baizan.daka.mvp.model

import com.baizan.daka.mvp.model.bean.NewsDetailBean
import com.baizan.daka.mvp.model.bean.NewsInfoBean
import com.baizan.daka.mvp.model.bean.NoticeInfoBean
import com.baizan.daka.net.BasePageResponse
import com.baizan.daka.net.bean.BasePageParam
import com.baizan.daka.net.bean.TaskParamBean
import com.baizan.daka.util.SchedulerUtils
import com.hazz.kotlinmvp.net.BaseResponse
import com.hazz.kotlinmvp.net.RetrofitManager
import io.reactivex.Observable

class NewsModel {

    fun loadNewslist(pageNo: Int): Observable<BaseResponse<BasePageResponse<NewsInfoBean>>> {
        val taskRequest = BasePageParam(pageNo, TaskParamBean())
        return RetrofitManager.service.getNewsList(
            taskRequest
        ).compose(SchedulerUtils.ioToMain())
    }

    fun loadHouseNewslist(): Observable<BaseResponse<BasePageResponse<NewsInfoBean>>> {
        val taskRequest = BasePageParam(1, TaskParamBean(), 3)
        return RetrofitManager.service.getNewsList(
            taskRequest
        ).compose(SchedulerUtils.ioToMain())
    }

    fun loadNoticeList():Observable<BaseResponse<List<NoticeInfoBean>>>{
        return RetrofitManager.service.getNoticeList(
        ).compose(SchedulerUtils.ioToMain())
    }
    fun loadNewsDetail(id: Long): Observable<BaseResponse<NewsDetailBean>> {
        return RetrofitManager.service.getNewsDetail(id.toString())
            .compose(SchedulerUtils.ioToMain())
    }
}